function getUserInfo () {
	$.ajax({
		url: '/my/userinfo',
		method: 'get',
		// headers: { Authorization: localStorage.getItem('token') || '' },
		success: res => {
			if (res.status !== 0) return layer.msg(res.message);
			let username = res.data.nickname || res.data.username;
			$('.welcome em').html(username);
			if (res.data.user_pic === null) {
				$('.avatar').show().html(username.slice(0, 1).toUpperCase());
				$('.layui-nav-img').hide();
			} else {
				$('.avatar').hide();
				$('.layui-nav-img').show().prop('src', res.data.user_pic);
			}
		}
	});
}

$(function () {
	getUserInfo();
	$('.logout').on('click', function () {
		layer.confirm('确定退出登录? ', { 'icon': 3, 'title': '提示' }, index => {
			localStorage.removeItem('token');
			location.href = '/login.html';
			layer.close(index);
		});
	});
});